#pragma once
#include "protocol.hpp"
class Cal
{
public:
    Cal() {}
    Response Excute(Request &req)
    {
        Response ret(0, 0);
        switch (req.Oper())
        {
        case '+':
            ret.Set(req.X() + req.Y(), 0);
            break;
        case '-':
            ret.Set(req.X() - req.Y(), 0);

            break;
        case '*':
            ret.Set(req.X() * req.Y(), 0);
            break;
        case '/':
        {
            int code = 0;
            if (req.Y() == 0)
            {
                code = 1;
                ret.Set(0,1);
            }
            else
            ret.Set(req.X() / req.Y(), code);
        }
        break;
        case '%':
        {
            int code = 0;
            if (req.Y() == 0)
            {
                code = 2;
                ret.Set(0,code);
            }
            else
            ret.Set(req.X() % req.Y(), code);
        }
        break;
        default:
            ret.Set(0, 3); // 非法操作
            break;
        }
        return ret;
    }
    ~Cal() {}

private:
};
